//
//  TestViewController.m
//  LearnObjC
//
//  Created by chaomeng on 2021/5/31.
//

#import "TestViewController.h"
#import "UIControl+QiEventInterval.h"
#import "Masonry.h"

@interface TestViewController ()

@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor lightGrayColor];
    button.frame = CGRectMake(30.0, self.view.bounds.size.height / 2, self.view.bounds.size.width - 30.0 * 2, 50.0);
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@(0).stringValue forState:UIControlStateNormal];
    [self.view addSubview:button];

    //! 设置按钮的点击响应间隔时间
    button.qi_eventInterval = 2.0;
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    button2.backgroundColor = [UIColor lightGrayColor];
    button2.frame = CGRectMake(30.0, self.view.bounds.size.height / 2/2, self.view.bounds.size.width - 30.0 * 2, 50.0);
    [button2 addTarget:self action:@selector(buttonClicked2:) forControlEvents:UIControlEventTouchUpInside];
    [button2 setTitle:@(0).stringValue forState:UIControlStateNormal];
    [self.view addSubview:button2];

    button2.layer.borderWidth = 2;
    button2.layer.borderColor = [UIColor redColor].CGColor;
    
    
}

#pragma mark - Action functions

- (void)buttonClicked:(UIButton *)sender {
    
    NSInteger titleInteger = sender.currentTitle.integerValue;
    [sender setTitle:@(++titleInteger).stringValue forState:UIControlStateNormal];
}

-(void)buttonClicked2:(UIButton *)sender{
    NSInteger titleInteger = sender.currentTitle.integerValue;
    [sender setTitle:@(++titleInteger).stringValue forState:UIControlStateNormal];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
